/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.teste;

import br.com.modelo.Usuario;
import java.util.Calendar;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author egberto
 */
public class AdicionaUsuario {
    
    public static void main(String args[]){
        EntityManagerFactory factory = Persistence.createEntityManagerFactory("default");
        EntityManager manager = factory.createEntityManager();
        
        manager.getTransaction().begin();
        
        Usuario usuario = new Usuario();
               
        usuario.setEmail("contato@teste.com.br");
        usuario.setDataDeCadastro(Calendar.getInstance());
        
        manager.persist(usuario);
        
        manager.getTransaction().commit();
        
        manager.close();
        factory.close();
    }
    
}
